;
layui.define([ "table", "form" ], function(exports) {
	tab = layui.table, form = layui.form;
	tab.render({
		elem : "#LAY-web-list",
		url : layui.setter.base + "admin/merch/user/listJson",
		cols : [ [
			{field:"orgCode",title:"所属机构"},
			{field:"merchCode",title:"所属商户"},
			{field:"userName",title:"用户名"},
			{field:"name",title:"客户号"},
			{field:"updateTime",title:"更新时间"},
			{title:"操作",width:160,align:"center",fixed:"right",toolbar:"#table-content-list"}
		] ],
		page : !0,
		limit : 10,
		limits : [ 10, 15, 20, 25, 30 ],
		text: {none: '暂无相关数据'}
	}), tab.on("tool(LAY-web-list)", function(row) {
		if ("update" === row.event) {
			parent.layer.open({
				type : 2,
				title : "机构用户编辑",
				content : layui.setter.base + "admin/merch/user/updatePage?id="
						+ row.data.id,
				maxmin : !0,
				area : [ '600px', '500px' ],
				btn : [ "确定", "取消" ],
				yes : function(index, layero) {
					// 点击确认触发 iframe 内容中的按钮提交
					layero.find('iframe').contents().find(
							"#layuiadmin-app-form-edit").click();
				}
			});
			return;
		}

		if ("delete" === row.event) {
			layer.confirm("确定删除吗？", function(e) {
				console.log(row.data);
				// 请求删除接口
				layui.admin.req({
					url : layui.setter.base + "admin/merch/user/delete?id="
							+ row.data.id + "&r=" + Math.random(),
					data : null,
					done : function(res) {
						if (res.code !== 0) {
							layer.msg(res.msg, {
								icon : 2
							});
						} else {
							layer.msg(res.msg, {
								icon : 1
							});
							layui.table.reload('LAY-web-list'); // 重载表格
							layer.close(e); // 再执行关闭
						}
					}
				});
			});
			return;
		}
	}), exports("merchUser", {})
});
